package cn.org.zx.common.file;

import java.net.*;
import java.io.*;

public class HtmlFileParser{
	public void getUrl(String strHttp,String strPathFileSave){	
		String sCurrentLine = ""; 
		String sTotalString = "";
		
		InputStream l_urlStream;   
		URL l_url = null;   
		HttpURLConnection l_connection;   
		BufferedReader l_reader;   
    
		try{
			l_url = new java.net.URL(strHttp);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}   

		try{
			l_connection = (java.net.HttpURLConnection) l_url.openConnection();
			l_connection.connect();
			l_urlStream = l_connection.getInputStream();
			l_reader = new java.io.BufferedReader(new java.io.InputStreamReader(l_urlStream,"utf-8"));
			while ((sCurrentLine = l_reader.readLine()) != null)
				sTotalString += sCurrentLine + "\n";
			
			//System.out.println(sTotalString);			
			OutputStream out = new FileOutputStream(strPathFileSave);
			BufferedWriter rd = new BufferedWriter(new OutputStreamWriter(out,"utf-8"));  
		    rd.write(sTotalString); 
		    rd.close();  
	        out.close();
	    } catch (IOException ioex) {
			ioex.printStackTrace();
		}
		
	}
	

	public static void main(String args[])
	{
		
    }
	
	//
}
